enum resultType {
    err = '错误输入', right = '对了', small = '太小了', big = '太大了'
}

function outOfScope(n:number) {
    return n < 0 || n > 9;
}

function equal(n:number, g:number) {
    return n == g;
}

export function game(g: number) {
    return function guess(n: number) {
        if (outOfScope(n)) {
            return resultType.err;
        }
        if (equal(n, g)) {
            return resultType.right;
        }
        if (n < g) {
            return resultType.small;
        }
        return resultType.big;
    };
}
